package user;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class LocalUser extends User {

	/**
	 * @param username
	 * @throws UnknownHostException 
	 */
	private LocalUser (String username) {
		super (username, (InetAddress)null) ;
		try {
			address = InetAddress.getLocalHost() ;
		} 
		catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
	
	private static final LocalUser LOCAL_USER = new LocalUser("");
	
	/**
	 * Set the username of the local user
	 * 
	 * @param username The new username
	 * @return The local user
	 */
	public static LocalUser setLocalUserName (String username){
		LOCAL_USER.username = username ;
		return LOCAL_USER ;
	}
	
	/**
	 * Get the local user
	 * 
	 * @return The local user
	 */
	public static LocalUser getLocalUser () {
		return LOCAL_USER ;
	}
	
	/**
	 * @param u The user
	 * @return true if the specified User is local user
	 */
	public static boolean isLocalUser (User u) {
		return u == LOCAL_USER ;
	}
	
}
